#ifndef UARTWORKER_H
#define UARTWORKER_H
#include <QObject>
#include <QThread>
#include <QSerialPort>
#include <QDebug>
#include "settings.h"

class uartWorker : public QObject {
    Q_OBJECT
public:
    explicit uartWorker(ResultSettings &r, QObject *parent = nullptr);
    ~uartWorker();

public slots:
    void openSerial(const QString &portName, int baudRate);
    void closeSerial();
    void writeData(const QByteArray &data);
    void processUart();

private slots:
    void handleReadyRead();

signals:
    void dataReceived(const QByteArray &data);
    void errorOccurred(const QString &error);

private:
    QSerialPort *serial;
    ResultSettings &resultSettings;
};

#endif // UARTWORKER_H
